﻿@model QuanLyGiaoVuUI.Models.GiangVien.GiangVienViewModel

@{
    ViewBag.Title = "ThongKeGiangVien";
    Layout = "";
}
<style>
    .thongkegiangdaygv {
        margin: 0 auto;
        font-size: 13px;
    }

    table#chitietthongtin {
        border-collapse: collapse;
    }

        table#chitietthongtin, table#chitietthongtin td, table#chitietthongtin th {
            border: 1px solid black;
        }

            table#chitietthongtin td {
                padding: 5px;
            }

    span {
        padding: 5px;
    }

    table#giaovieninfo tr td{
    text-align:left;
    }
.tenmon{
    text-align:left;
    }
    .info-thongkegv {
        font-weight:bold;
    }
</style>

 <div class="thongkegiangdaygv">
        @if (Model != null && !Model.ThinhGiang)
        {
            int giochuan = Model.ChucDanh.GioChuanCacMon;
            double k1 = 1;
            double k2 = 0;
            double tempk2 = 0.004;
            double k3 = 0;
            if (Model.HocKyHienTai != null)
            {
                if (Model.HocKyHienTai.TenHocKy == QuanLyGiaoVuService.Utilities.ThamSoConstantUtility.TENHOCKYHE)
                {
                    k3 = 0.2;
                }
            }
            double k4 = 0.6;
            double k5 = 1.2;
            double k6 = 1;
            double quidoi = 0;
            String chucdanh = Model.ChucDanh.VietTat.Trim();
            String hocvi = Model.HocVi.VietTat.Trim();
            bool isHasK1 = false;
            int tilegiam = 0;

            double tongcong = 0;

            int sotietduocgiam = 0;
            int sotiettrongchuan = 0;
            double sotietdayquichuan = 0;
            if (chucdanh == "GS")
            {
                k1 = 1.6;
                isHasK1 = true;
            }
            else
            {
                if (chucdanh == "GVCC")
                {
                    k1 = 1.5;
                    isHasK1 = true;
                }
                else
                {
                    if (chucdanh == "PGS")
                    {
                        k1 = 1.4;
                        isHasK1 = true;
                    }
                    else
                    {
                        if (chucdanh == "GVC")
                        {
                            if (hocvi == "TS")
                            {
                                k1 = 1.3;
                            }
                            else
                            {
                                k1 = 1.2;
                            }
                            isHasK1 = true;
                        }
                        else //the end is GV level
                        {
                            if (hocvi == "ThS")
                            {
                                k1 = 1.1;
                                isHasK1 = true;
                            }
                        }

                    }
                }
            }

            if (!isHasK1)
            {
                if (hocvi == "TS")
                {
                    k1 = 1.2;
                }
                else
                {
                    if (hocvi == "ThS")
                    {
                        k1 = 1.1;
                    }
                }
            }
            
    
            <table class="data display datatable" id="giaovieninfo" style="margin: 20px auto; width: 100%;">
                <tr>
                    <td><span>Họ và Tên:</span><span class="info-thongkegv">@Model.HoTenGV</span></td>
                    <td><span>Mã số:</span> <span class="info-thongkegv">@Model.MaGiangVien</span></td>
                </tr>
                <tr>
                    <td colspan="2">
                        <span>Đơn vị(Khoa/Bộ Môn):</span><span class="info-thongkegv">Khoa Công Nghệ Phần Mềm</span>@if (Model.BoMon != null) {<span class="info-thongkegv">/@Model.BoMon.TenBoMon </span>}
                    </td>
                </tr>
                <tr>
                    <td><span>Chức Danh:</span> <span class="info-thongkegv">@Model.ChucDanh.TenChucDanh </span></td>
                    <td><span>Học Vị:</span><span class="info-thongkegv">@Model.HocVi.TenHocVi (@Model.HocVi.TenHocVi)</span></td>
                </tr>
                <tr>
                    <td><span>Chức Vụ:</span>
                        @if (Model.DanhSachChucVu != null)
                        {
                            var counterCV=Model.DanhSachChucVu.Count();
                            var ctCV=0;
                            foreach (var cv in Model.DanhSachChucVu)
                            {
                                ctCV++;
                                if (cv.TiLeGiam > tilegiam)
                                {
                                    tilegiam = cv.TiLeGiam;
                                }
                            <span class="info-thongkegv">@cv.TenChucVu @(counterCV>ctCV?"-":"")</span> 
                            }
                            sotietduocgiam = (giochuan * tilegiam / 100);
                            sotiettrongchuan = (giochuan * (100 - tilegiam) / 100);
                        }
                    </td>
                    <td><span>Học Hàm: </span>@if(Model.HocHam!=null){<span class="info-thongkegv">@Model.HocHam.TenHocHam</span> <span class="info-thongkegv">@Model.HocHam.VietTat</span> }</td>
                </tr>
                <tr>
                    <td colspan="2"><span>Địa chỉ:</span><span class="info-thongkegv"> @Model.DiaChi</span></td>
                </tr>
                <tr>
                    <td><span>Số ĐiệnThoại:</span><span class="info-thongkegv">@Model.SoDienThoai</span></td>
                    <td><span>Email:</span><span class="info-thongkegv">@Model.Email</span></td>
                </tr>
                <tr>
                    <td><span>Số tiết Chuẩn:</span><span class="info-thongkegv">@Model.ChucDanh.GioChuanCacMon</span></td>
                    <td><span>Tỉ Lệ Được Giảm:</span>
                        @if (Model.GioiTinh.Trim() == "1")
                        {
                            <span class="info-thongkegv">@tilegiam %</span>
                        }
                        else
                        {
                            <span class="info-thongkegv">@(tilegiam += 5) %</span>
                        }
                        @if (Model.DanhSachLopMonHoc != null)
                        {
                            //double tempQuiDoi = 0;
                            foreach (var lmh in Model.DanhSachLopMonHoc)
                            {
                                
                                if (lmh.LoaiLop == QuanLyGiaoVuService.Utilities.ThamSoConstantUtility.LOAILOPLYTHUYET)
                                {
                                    //k1 = 1.4;
                                    int sotietday = lmh.MonHoc.SoTinChiLyThuyet * 15;
                                    if (lmh.SiSoThucTe < 50)
                                    {
                                        k2 = 0;
                                    }
                                    else
                                        if (lmh.SiSoThucTe >= 201)
                                        {
                                            k2 = 0.6;
                                        }
                                        else
                                        {
                                            k2 = tempk2 * (double)(lmh.SiSoThucTe - 50);
                                        }
                                    double tempQuiDoi = (k1 + k2 + k3) * k5 * k6 * sotietday;
                                    sotietdayquichuan += tempQuiDoi;
                                }
                                
                                int soGVLopHoc = 2; //lớp thực hành phải chia đôi sinh viên.
                                if (lmh.MaGiangVien1 == null || lmh.MaGiangVien2 == null)
                                {
                                    soGVLopHoc = 1;
                                }
                                else
                                {
                                    if (lmh.MaGiangVien1 == lmh.MaGiangVien2)
                                    {
                                        soGVLopHoc = 1;
                                    }
                                }
                                
                                if (lmh.LoaiLop == QuanLyGiaoVuService.Utilities.ThamSoConstantUtility.LOAILOPTHUCHANH1)
                                {
                                    k4 = 0.6;
                                    double quidoitiet = ((double)lmh.SiSoThucTe / (QuanLyGiaoVuService.Utilities.ThamSoConstantUtility.SO_SINHVIEN_1_NHOMTHUCHANH * soGVLopHoc));
                                    quidoitiet = (quidoitiet > 2 ? 2 : quidoitiet);
                                    int sotietday = (lmh.MonHoc.TongSoTinChi - lmh.MonHoc.SoTinChiLyThuyet) * 15;
                                    double quidoithuchanh = quidoitiet * (k3 + k4) * k5 * sotietday;
                                    sotietdayquichuan += quidoithuchanh;
                                }
                                if (lmh.LoaiLop == QuanLyGiaoVuService.Utilities.ThamSoConstantUtility.LOAILOPTHUCHANH2)
                                {
                                    k4 = 0.45;
                                    double quidoitiet = ((double)lmh.SiSoThucTe / (QuanLyGiaoVuService.Utilities.ThamSoConstantUtility.SO_SINHVIEN_1_NHOMTHUCHANH * soGVLopHoc));
                                    quidoitiet = (quidoitiet > 2 ? 2 : quidoitiet);
                                    int sotietday = (lmh.MonHoc.TongSoTinChi - lmh.MonHoc.SoTinChiLyThuyet) * 15;
                                    double quidoithuchanh = quidoitiet * (k3 + k4) * k5 * sotietday;
                                    sotietdayquichuan += quidoithuchanh;
                                }
                            }
                        }
                        @if (Model.DanhSachDeTai != null)
                        {
                            foreach (var detai in Model.DanhSachDeTai)
                            {
                                int soSV = 2;
                                int sotietDeTai = 15;
                                int quidoiDeTai = soSV * sotietDeTai;
                                sotietdayquichuan += quidoiDeTai;
                            }
                        }
                    </td>
                    <td><span>Số Tiết Được Giảm:</span><span class="info-thongkegv">@sotietduocgiam</span></td>
                </tr>
                <tr>
                    <td><span>Số tiết dạy quy chuẩn:</span><span class="info-thongkegv">@sotietdayquichuan</span></td>
                    <td><span>Số tiết trong chuẩn:</span><span class="info-thongkegv">@sotiettrongchuan</span></td>
                    <td><span>Số tiết ngoài chuẩn:</span><span class="info-thongkegv">@(sotietdayquichuan - sotiettrongchuan)</span></td>
                </tr>
            </table>
            <table id="chitietthongtin" class="data display datatable" style="width: 98%;">
                <tr>
                    <th>Mã Môn</th>
                    <th>Tên Môn</th>
                    <th>Lớp</th>
                    <th>Sĩ số</th>
                    <th>Số tiết</th>
                    <th>K1</th>
                    <th>K2</th>
                    <th>K3</th>
                    <th>K4</th>
                    <th>K5</th>
                    <th>K6</th>
                    <th>Quy đổi</th>
                </tr>
                @if (Model.DanhSachLopMonHoc != null)
                {
                    bool flagLT = true;
                    bool flagTH1 = true;
                    bool flagTH2 = true;
                    foreach (var lmh in Model.DanhSachLopMonHoc)
                    {
                        if (lmh.LoaiLop == QuanLyGiaoVuService.Utilities.ThamSoConstantUtility.LOAILOPLYTHUYET)
                        {
                            //k1 = 1.4;
                            int sotietday = lmh.MonHoc.SoTinChiLyThuyet * 15;
                            if (lmh.SiSoThucTe < 50)
                            {
                                k2 = 0;
                            }
                            else
                                if (lmh.SiSoThucTe >= 201)
                                {
                                    k2 = 0.6;
                                }
                                else
                                {
                                    k2 = tempk2 * (double)(lmh.SiSoThucTe - 50);
                                }
                            if (lmh.MonHoc.MaMonHoc.Trim() == "SE417")
                            {
                                quidoi = (double)lmh.SiSoThucTe * 2;
                            }
                            else
                            {
                                quidoi = (k1 + k2 + k3) * k5 * k6 * sotietday;
                            }
                            tongcong += quidoi;
                            if (flagLT)
                            {
                    <tr>
                        <td colspan="2">Giảng Dạy Lý Thuyết</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>       
                                flagLT = false;
                            }
                    <tr>
                        <td>@lmh.MonHoc.MaMonHoc</td>
                        <td class="tenmon">@lmh.MonHoc.TenMonHoc</td>
                        <td></td>
                        <td>@lmh.SiSoThucTe</td>
                        <td>@(sotietday)</td>
                        <td>@k1</td>
                        <td>@k2</td>
                        <td>@k3</td>
                        <td>0.6</td>
                        <td>1.2</td>
                        <td>1</td>
                        <td>@quidoi</td>
                    </tr>
                        }
                        int soGVLopHoc = 2; //lớp thực hành phải chia đôi sinh viên.
                        if (lmh.MaGiangVien1 == null || lmh.MaGiangVien2 == null)
                        {
                            soGVLopHoc = 1;
                        }
                        else
                        {
                            if (lmh.MaGiangVien1 == lmh.MaGiangVien2)
                            {
                                soGVLopHoc = 1;
                            }
                        }
                        ///check loai lop thực hành
                        if (lmh.LoaiLop == QuanLyGiaoVuService.Utilities.ThamSoConstantUtility.LOAILOPTHUCHANH1)
                        {
                            k4 = 0.6;
                            double quidoitiet = ((double)lmh.SiSoThucTe / (QuanLyGiaoVuService.Utilities.ThamSoConstantUtility.SO_SINHVIEN_1_NHOMTHUCHANH * soGVLopHoc));
                            quidoitiet = (quidoitiet > 2 ? 2 : quidoitiet);
                            int sotietday = (lmh.MonHoc.TongSoTinChi - lmh.MonHoc.SoTinChiLyThuyet) * 15;
                            double quidoithuchanh = quidoitiet * (k3 + k4) * k5 * sotietday;
                            tongcong += quidoithuchanh;
                            if (flagTH1)
                            {
                    <tr>
                        <td colspan="2">Giảng Dạy thực hành 1</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>       
                                flagTH1 = false;
                            }
                    <tr>
                        <td>@lmh.MonHoc.MaMonHoc</td>
                        <td class="tenmon">@lmh.MonHoc.TenMonHoc</td>
                        <td></td>
                        <td>@lmh.SiSoThucTe</td>
                        <td>@(sotietday)</td>
                        <td>@k1</td>
                        <td>0</td>
                        <td>0</td>
                        <td>@k4</td>
                        <td>@k5</td>
                        <td>@k6</td>
                        <td>@quidoithuchanh</td>
                    </tr>
                        }
                        if (lmh.LoaiLop == QuanLyGiaoVuService.Utilities.ThamSoConstantUtility.LOAILOPTHUCHANH2)
                        {
                            k4 = 0.45;
                            double quidoitiet = ((double)lmh.SiSoThucTe / (QuanLyGiaoVuService.Utilities.ThamSoConstantUtility.SO_SINHVIEN_1_NHOMTHUCHANH * soGVLopHoc));
                            quidoitiet = (quidoitiet > 2 ? 2 : quidoitiet);
                            int sotietday = (lmh.MonHoc.TongSoTinChi - lmh.MonHoc.SoTinChiLyThuyet) * 15;
                            double quidoithuchanh = quidoitiet * (k3 + k4) * k5 * sotietday;
                            tongcong += quidoithuchanh;
                            if (flagTH2)
                            {
                    <tr>
                        <td colspan="2">Giảng Dạy thực hành 2</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>       
                                flagTH2 = false;
                            }
                    <tr>
                        <td>@lmh.MonHoc.MaMonHoc</td>
                        <td class="tenmon">@lmh.MonHoc.TenMonHoc</td>
                        <td></td>
                        <td>@lmh.SiSoThucTe</td>
                        <td>@(sotietday)</td>
                        <td>@k1</td>
                        <td>0</td>
                        <td>0</td>
                        <td>@k4</td>
                        <td>@k5</td>
                        <td>@k6</td>
                        <td>@quidoithuchanh</td>
                    </tr>
                        }

                    }
                }
                @if (Model.DanhSachDeTai != null)
                {
                    int sttDeTai = 0;
                    <tr>
                        <td colspan="2">Hướng dẫn đồ án</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>       
                    foreach (var detai in Model.DanhSachDeTai)
                    {
                        int soSV = 2;                        
                        int sotietDeTai = 15;
                        int quidoiDeTai = sotietDeTai;
                        tongcong += quidoiDeTai;
                    <tr>
                        <td>@(sttDeTai++)</td>
                        <td>@detai.TenDeTai</td>
                        <td></td>
                        <td>@soSV</td>
                        <td>@sotietDeTai</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td>@quidoiDeTai</td>
                    </tr>
                    }
                }
                <tr>
                    <td></td>
                    <td><b>Tổng cộng</b></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td class="tongcong" aria-valuetext="@tongcong">@tongcong</td>
                </tr>
            </table>  
        }
    </div>





